<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;

class CreateProductCategoriesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if (!Schema::hasTable('product_categories')) {
            Schema::create('product_categories', function (Blueprint $table) {
                $table->id();
                $table->string('name', 64)->comment('品类名');
                $table->integer('parent_id')->default(0)->comment('上级品类ID');
                $table->integer('order')->default(0)->comment('排序');
                $table->enum('status', ['normal', 'ban'])->default('ban')->comment('使用状态');
                $table->softDeletes();
                $table->timestamps();
            });
            DB::statement("ALTER TABLE `product_categories` comment '商品品类表'");
        }
        
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('product_categories');
    }
}
